/*
 * ========================================================================
 *
 *       Filename:  misc.h
 *
 *    Description:  This handles file processing of decks.
 *
 *        Version:  1.0
 *        Created:  05/03/2010 02:00:08 PM
 *       Revision:  none
 *       Compiler:  g++
 *
 *         Author:  Alex Avance (aa), aravance@gmail.com
 *        Company:  independent
 *
 * ========================================================================
 *
 * Copyright (C) 2010 Alex Avance
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
 * 1307, USA.
 *
 * ========================================================================
 */
#ifndef _MISC_H_
#define _MISC_H_

#include "card.h"
#include "deck.h"
#include "wx/xml/xml.h"

StudyDeck LoadDeck ( const wxString &filename );
bool LoadDeck ( const wxString &filename, StudyDeck &deck );
bool SaveDeck ( const wxString &filename, const StudyDeck &deck );
wxXmlProperty* MakeCardProps ( const StudyCard &card );

template <class T>
size_t StripPunct ( T &str )
{
  T copy= str;
  str.clear();
  size_t remCount= 0;

  for ( size_t i= 0; i < copy.Len(); ++i )
    if ( !wxIspunct( copy[i] ) )
      str.append( copy[i] );
    else
      ++remCount;

  return remCount;
}

template <class T>
T StripPunctC ( T str )
{
  StripPunct( str );
  return str;
}

#endif // _MISC_H_

